import request from '@/utils/request'

// PTZ控制
export function ptzControl(channelId, command) {
  return request({
    url: `/channels/${channelId}/ptz/control`,
    method: 'post',
    data: command
  })
}

// 获取PTZ状态
export function getPTZStatus(channelId) {
  return request({
    url: `/channels/${channelId}/ptz/status`,
    method: 'get'
  })
}

// 获取PTZ配置
export function getPTZConfig(channelId) {
  return request({
    url: `/channels/${channelId}/ptz/config`,
    method: 'get'
  })
}

// 设置PTZ配置
export function setPTZConfig(channelId, config) {
  return request({
    url: `/channels/${channelId}/ptz/config`,
    method: 'put',
    data: config
  })
}

// 获取预设位列表
export function getPresets(channelId) {
  return request({
    url: `/channels/${channelId}/presets`,
    method: 'get'
  })
}

// 添加预设位
export function addPreset(channelId, presetData) {
  return request({
    url: `/channels/${channelId}/presets`,
    method: 'post',
    data: presetData
  })
}

// 调用预设位
export function gotoPreset(channelId, presetToken) {
  return request({
    url: `/channels/${channelId}/presets/${presetToken}/goto`,
    method: 'post'
  })
}

// 删除预设位
export function removePreset(channelId, presetToken) {
  return request({
    url: `/channels/${channelId}/presets/${presetToken}`,
    method: 'delete'
  })
}

// 设置预设位
export function setPreset(channelId, presetToken, presetName) {
  return request({
    url: `/channels/${channelId}/presets/${presetToken}`,
    method: 'put',
    data: { name: presetName }
  })
}

// PTZ移动
export function ptzMove(channelId, direction, speed) {
  return request({
    url: `/channels/${channelId}/ptz/move`,
    method: 'post',
    data: {
      direction,
      speed
    }
  })
}

// PTZ停止
export function ptzStop(channelId) {
  return request({
    url: `/channels/${channelId}/ptz/stop`,
    method: 'post'
  })
}

// PTZ缩放
export function ptzZoom(channelId, direction, speed) {
  return request({
    url: `/channels/${channelId}/ptz/zoom`,
    method: 'post',
    data: {
      direction,
      speed
    }
  })
}

// 获取PTZ能力集
export function getPTZCapabilities(channelId) {
  return request({
    url: `/channels/${channelId}/ptz/capabilities`,
    method: 'get'
  })
}